// SlotGutListBox.cpp : implementation file
//

#include "stdafx.h"
#include "AUSlotsTester.h"
#include "SlotGutListBox.h"
#include "SQLServerSession.h"
#include "AUSlotsGuts.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSlotGutListBox

CSlotGutListBox::CSlotGutListBox()
{
}

CSlotGutListBox::~CSlotGutListBox()
{
}


BEGIN_MESSAGE_MAP(CSlotGutListBox, CListBox)
	//{{AFX_MSG_MAP(CSlotGutListBox)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSlotGutListBox message handlers

void CSlotGutListBox::Load( LPCTSTR szServer, bool bUseIntegratedSecurity, LPCTSTR szUser, LPCTSTR szPassword, LPCTSTR szDatabase )
{
	CWaitCursor wait;

	ResetContent();

	SetTabStops( 20 );

	CSQLServerSession session;

	if ( SUCCEEDED( session.Open( szServer, bUseIntegratedSecurity, szUser, szPassword, szDatabase ) ) )
	{
		CAUSlotsGuts guts;

		if ( SUCCEEDED( guts.Open( &session ) ) )
		{
			while ( guts.MoveNext() == S_OK )
			{
				CString str;

				str.Format( _T( "%d\t%s" ), guts.m_nGutsID, guts.m_szGutsDescription );

				AddString( str );
			}
		}
	}
}
